import axios from "axios";
import service from "@/config/index";

export default {
  // 财务模块-运单列表查询
  search (params) {
    return axios.post(`${service.serviceFinance}/waybill/search`, params);
  },
  // 查询列表合计
  getListTotal (params) {
    return axios.post(`${service.serviceFinance}/waybill/search/total`, params);
  },
  // 对账单列表合计
  getBillListTotal (params) {
    return axios.post(`${service.serviceFinance}/bill/search/total`, params);
  },
  // 新增应收对账单
  createReceivable (params) {
    return axios.post(`${service.serviceFinance}/bill/receivable`, params);
  },
  // 新增应付对账单
  createPayable (params) {
    return axios.post(`${service.serviceFinance}/bill/payable`, params);
  },
  // 发送对账单
  sendOut (params) {
    return axios.post(`${service.serviceFinance}/bill/send`, params);
  },
  // 获取对账单详情
  getBillDetail (params) {
    return axios.post(`${service.serviceFinance}/bill/getBillById`, params);
  },
  updateBill (params) {
    return axios.put(`${service.serviceFinance}/bill/update`, params);
  },
  // 增加明细
  addRes (params) {
    return axios.post(`${service.serviceFinance}/bill/specs/add`, params);
  },
  // 删除明细
  deleteRes (params) {
    return axios.post(`${service.serviceFinance}/bill/specs/delete`, params);
  },
  // 批量删除明细
  batchDeleteRes (params) {
    return axios.post(`${service.serviceFinance}/bill/specs/deletes`, params);
  },
  // 修改明细
  updateRes (params) {
    return axios.put(`${service.serviceFinance}/bill/specs/update`, params);
  },
  // 撤回对账单
  recallBill (params) {
    return axios.post(`${service.serviceFinance}/bill/recall`, params);
  },
  // 同意
  agree (params) {
    return axios.post(`${service.serviceFinance}/bill/agree`, params);
  },
  // 拒绝
  refuse (params) {
    return axios.post(`${service.serviceFinance}/bill/refuse`, params);
  },
  // 获取收付款详情
  getBillInfo (params) {
    return axios.post(`${service.serviceFinance}/bill/record/getById`, params);
  },
  // 获取收付款详情
  getBillInfoNew (params) {
    return axios.post(`${service.serviceFinance}/bill/record/getByWaybillId`, params);
  },
  // 收款
  billCollect (params) {
    return axios.post(`${service.serviceFinance}/bill/record/collect`, params);
  },
  // 付款
  billPayment (params) {
    return axios.post(`${service.serviceFinance}/bill/record/payment`, params);
  },
  // 未收、已收款查询
  getCollectionInfo (waybillId) {
    return axios.get(`${service.serviceFinance}/waybill/${waybillId}`);
  },
  // 收付款-列表合计
  getBillTotal (params) {
    return axios.post(`${service.serviceFinance}/bill/record/search/total`, params);
  },
  // 对账单发票详情
  getFinanceInvoicingDetail (billId) {
    return axios.get(`${service.serviceFinance}/bill/${billId}`);
  },
  // 对账单发票-单个详情
  getFinanceInvoicing (invoiceId) {
    return axios.get(`${service.serviceFinance}/bill/${invoiceId}`);
  },
  // 新增单个发票
  addFinanceInvoicing (params) {
    return axios.post(`${service.serviceFinance}/bill/invoice/add`, params);
  },
  // 修改单个发票
  updateFinanceInvoicing (params) {
    return axios.put(`${service.serviceFinance}/bill/invoice/${params.billId}/${params.invoiceId}/update`, params);
  },
  // 删除单个对账单发票
  deleteFinanceInvoicing (billId, invoiceId) {
    return axios.delete(`${service.serviceFinance}/bill/invoice/${billId}/${invoiceId}/delete`, { data: { billId, invoiceId } })
  },
};
